<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>简体字转为繁体字 (自己找接口)</title>
</head>
<body>
  <input type="text" id="ipt">
  <button>转繁体</button>
  <script>
    var ipt = document.getElementById('ipt')
    // oninput：往input中输入内容，则触发
    ipt.oninput = function () {
      var val = ipt.value
      var xhr = new XMLHttpRequest()
      xhr.open('GET', 'https://apis.tianapi.com/charconvert/index?key=1abddedd769e196b38ba149d49817d13&text=' + val)
      xhr.send()
      xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
          var obj = JSON.parse(xhr.responseText)
          function fn() {
            console.log(obj.result.outtext)
          }
        }
      }
    }
  </script>
</body>
</html>